﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PhotoGalleryEnteties;

namespace PhotogalleryModel
{
    public class SubscribeRepository
    {
        private IContext _context;

        public SubscribeRepository (ModelContext context)
        {
            
            _context = context.Context;
        }

        public void AddSubscribeForComments(Guid user, int photo, DateTime observeDate)
        {
            
            _context.AddSubscribeForComments(user, photo, observeDate);
        }

        public void AddSubscribeForComments(GalleryUser  user, PhotoInfo  photo, DateTime observeDate)
        {
            if (user == null || photo == null)
                throw new ArgumentNullException();
            AddSubscribeForComments(user.UserId, photo.PhotoId, observeDate);
        }




        public IEnumerable<Guid> SubscribedUsersIds(PhotoInfo photo)
        {
            if (photo == null)
                throw new ArgumentNullException();
            return SubscribedUsersIds(photo.PhotoId);
        }


        public IEnumerable<Guid> SubscribedUsersIds(int photo)
        {

            return _context.SubscribedUsersIds(photo);
        }

        public bool UpdateSubscribe(GalleryUser user, PhotoInfo photo, DateTime observeDate)
        {
            if (user == null || photo == null)
                throw new ArgumentNullException();
            return UpdateSubscribe(user.UserId, photo.PhotoId, observeDate);
        }

        public bool UpdateSubscribe(Guid user, int photo, DateTime observeDate)
        {
             return _context.UpdateSubscribe(user, photo, observeDate);
        }


        public IEnumerable<PhotoInfo> RecentCommented(Guid userId)
        {
            return _context.RecentCommented(userId);
        }

        public bool SubscribeExists(GalleryUser user, PhotoInfo photo)
        {
            if(user==null&&photo==null)
                throw new ArgumentNullException();
            return SubscribeExists(user.UserId, photo.PhotoId);
        }

        public bool SubscribeExists(Guid  user, int  photo)
        {
            return _context.SubscribeExists(photo, user);
        }
    }
}
